package com.zk.shop.mapper;

import com.zk.shop.pojo.Role;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RoleMapper {

    /**
     * 分页查询角色列表
     * @param id
     * @return
     */
    @Select("<script>"+"select * from role where 1 = 1"+"<when test='id!=null'>"+"and id=#{id}"+"</when></script>")
    List<Role> roleList(Integer id);

    /**
     * 修改角色名称
     * @param rolename
     * @param id
     * @return
     */
    @Update("update role set rolename = #{rolename} where id = #{id}")
    Integer saveRole(String rolename,Integer id);

    /**
     * 删除角色
     * @param id
     * @return
     */
    @Delete("delete from role where id = #{id}")
    Integer removeRole(Integer id);

    /**
     * 新增角色
     * @param rolename
     * @return
     */
    @Insert("insert into role(rolename) values(#{rolename})")
    Integer pushRole(String rolename);
}
